using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
using System.Windows.Forms;
using System.Data;


namespace Ketnoicsdl
{
    class Display
    {
      public Display(ListView lst, ComboBox cbo)
        {
            this.lst = lst;
            this.cbo = cbo;
        }
      public Display(ListView lst)
        {
            this.lst = lst;
        }
      public Display(ComboBox cbo)
        {
            this.cbo = cbo;
        }
      public void  DisplayListview(DataTable table)
        {
            lst.Items.Clear();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                lst.Items.Add(table.Rows[i][0].ToString());
                for (int j= 1; j < lst.Items.Count; j++)
                    lst.Items[i].SubItems.Add(table.Rows[i][j].ToString());
            }
        }
        public void DisplayListview(DataTable table, params string[] tieude)
        {
            foreach (string str in tieude)
            {
                lst.Columns.Add(str);

            }
            for (int i = 0; i < table.Rows.Count; i++)
            {
                lst.Items.Add(table.Rows[i][0].ToString());
                for (int j = 1; j < lst.Columns.Count; j++)
                    lst.Items[i].SubItems.Add(table.Rows[i][j].ToString());
            }
        }
        public void DisplayCombobox(DataTable table, string giatrian, string giatrihien)
        {
            if (table != null)
            {
                cbo.DataSource = table;
                cbo.ValueMember = giatrian;
                cbo.DisplayMember = giatrihien;
            }
        }
      ListView lst;
      ComboBox cbo;
        
    }
}
